# 用户模型类的序列化器
from rest_framework.serializers import ModelSerializer

from apps.users.models import Users


class UserModelSerializer(ModelSerializer):
    class Meta:
        model = Users
        fields = ['id', 'username', 'mobile', 'email', 'password']

    # 重写 create
    def create(self, validated_data):
        user = Users.objects.create_user(**validated_data)

        return user
